
//% color="#cf1256" iconWidth=50 iconHeight=40
namespace t2stools{
    
    //% block="语音合成初始化 " blockType="command"
    export function t2sinit(parameter: any, block: any) {

        Generator.addImport(`\nimport pyttsx3 \nengine = pyttsx3.init() \n`)
    
        
    }

  
    //% block="设置语音合成音量 [valume] 语速 [speed] " blockType="command"
    //% valume.shadow="range" valume.params.min=0    valume.params.max=100    valume.defl=50  
    //% speed.shadow="range" speed.params.min=0    speed.params.max=200    speed.defl=200 


    export function t2sinit_rp(parameter: any, block: any) {
        let valume=parameter.valume.code/100;
        let speed=parameter.speed.code;
        
        Generator.addImport(`\nengine.setProperty('volume',${valume}) \nengine.setProperty('rate',${speed}) \n`)

        
        
    }
    
    //% block="朗读内容 [text] " blockType="command"
    //% text.shadow="String" text.defl="你好"


    export function t2sinit_rvboard(parameter: any, block: any) {
        let text=parameter.text.code;

        Generator.addCode(`\nengine.say('${text}') \nengine.runAndWait() \n`)

        
        
    }

    function replaceQuotationMarks(str:string){
            str=str.replace(/"/g, ""); //去除所有引号
            return str
    }


    
}
